package entity.connector;

import entity.bean.House;
import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 *
 * @author 52571783
 */
public class SeatUploader {
    private PreparedStatement ps;

    public SeatUploader(House house) {
        try {
            // initialize the seats of the house
            Connection con = ConnectionProvider.getCon();
            ps = con.prepareStatement("DELETE FROM unavailable_seat WHERE house_id = ?");
            ps.setInt(1, house.getId());
            ps.executeUpdate();
            // set ps for setUnavailableSeat()
            ps = con.prepareStatement("INSERT INTO unavailable_seat VALUES (?,?,?)");
            ps.setInt(1, house.getId());
        } catch (Exception e) {
        }
    }

    public void setUnavailableSeat(int row, int col) {
        try {
            ps.setInt(2, row);
            ps.setInt(3, row);
            ps.executeUpdate();
        } catch (Exception e) {
        }
    }
}
